<html>
	<head>
		<style>
			form {margin:0 0 0 0}
			body {background:#ebebeb}
			.formcells {background:#ffffff}
			.formheader {background:#9999ff;color:#ffffff;height:20px}
			.formbackground {background:#6b6b6b}
			.TABLE_BACKGROUND {background:#cccccc;}
			.TABLE_HEADER {background:#66ccff;}
			.TABLE_DATA {background:#FFFFFF;}
			.PAGE_HEADER_LIGHT {background:#fefefe;}
			.PAGE_HEADER {background:#ebebeb;}
			.PAGE_HEADER_dark {background:#ababab;}
			.PAGE_SPLITTER{background:#cccccc;}
			.LIST_HEADER_LIGHT {background:#ccccFF;}
			.layout_menu_folder {color:#9999ff;text-decoration:none}
			.LAYOUT_DIRECTORY {background:#ebebeb;vertical-align:top;}
			.LAYOUT_FORM{background:#ebebeb;vertical-align:top;}
			td {font-size:9pt}
		</style>
			
	</head>
	<body background="/images/bg.gif" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" style="height:100%">
			<tr class="formbackground">
				<td class="formbackground"><table width="100%" cellpadding="3" cellspacing="1" border="0" style="height:100%">
					<tr class="formcells">
						<td width="100%" height="20" class="formheader"><b>Menu</b></td>
					</tr>
					<tr class="formcells">
						<td class="formcells" valign="top"><span height="100%" id="directory"></span></td>
					</tr>
				</table></td>
			</tr>
		</table>
		<script>
				indent			= Array();
 				toggle		 	= Array();
 				toggle[-1] 		= Array(-1,true);
 				counter			= Array();
 				counter[0]=1;
				menu_list		= parent.menu_list;
				var count = Array();
				
				for (index=0;index < menu_list.length;index++){
					toggle[index]	= Array(menu_list[index][0],false);
				}

				
				
				function confirm_deletion(loc){
					if (confirm("Are your Sure?")){
						window.location=loc;
					}
				}
				function edit(loc){
					for(index=0;index < menu_list.length;index++){
						if (menu_list[index][0]==loc){
							found=index;
						}
					}
					d 						= parent.document.layout_form;
					tmpstr 					= new String(menu_list[found][2]);
					pos 					= tmpstr.lastIndexOf("/");
					if (pos!=-1){
						if (pos>0){
							directory_location	 	= tmpstr.substring(0,pos+1);
						}else{
							if(pos=0){
								pos=1;
							}
							directory_location	 	= "/";
						}
						url 				= tmpstr.substring(pos+1,tmpstr.length);
					}
					dir_found=-1;
					for (index=0; index < d.menu_directory.options.length;index++){
						if (d.menu_directory.options[index].value==directory_location){
							dir_found=index;
						 	d.menu_directory.options[index].selected=true;
						}
					}
					if (dir_found==-1){
						d.menu_directory.options[0].selected=true;
						url = new String(menu_list[found][2]).substring(1);
					}
					
					display_options = new String(menu_list[found][6]).split('|');
					for (x=0;x < d.layout_format.length;x++){
						d.layout_format[x].checked=false
						for (y=0;y < display_options.length;y++){
							if (d.layout_format[x].value == display_options[y]){
								d.layout_format[x].checked=true
							}
						}
					}
					d.menu_identifier.value	= menu_list[found][0];
					d.menu_label.value		= menu_list[found][1];
					d.menu_url.value		= url;
					d.previous_url.value	= menu_list[found][2];
				}
		
				function link_toggle(linkid){
					for (index=0,len=menu_list.length;index < len;index++){
						if (linkid==menu_list[index][0]){
							toggle[index][1] = !toggle[index][1];
						}
					}
					draw_menu();
				}
		
				function draw_menu(){
					//menu_list = ;
					level = 0;
					prev_level = 0;
					depth =0;
					for (index=0,len=menu_list.length;index < len;index++){
						if (depth < menu_list[index][3]){
							depth=menu_list[index][3];
						}
					}
					output ='<table width="100%" border="0" cellpadding="0" cellspacing="0">\n';
					if (!toggle[-1][1]){
						output +='<tr>\n<td width="10"><a class="layout_menu_folder" href="javascript:link_toggle(-1);"><img src="images/plus.gif" border="0"/></a></td>\n<td width="100%" colspan="'+(depth+1)+'">&nbsp;Root</td>\n</tr>\n';
					}else{
						output +='<tr>\n<td width="10"><a class="layout_menu_folder" href="javascript:link_toggle(-1);"><img src="images/minus.gif" border="0"/></a></td>\n<td width="100%" colspan="'+(depth+1)+'">&nbsp;Root</td>\n</tr>\n';
						output += display_children(1,-1);
					}
					output+="</table>\n";
					document.all.directory.innerHTML=output;
				}
				
				function display_children(d,loc){
					var index=0;
					var output="";
					var NEW_DEPTH=d;
					var total = counter[d];
					count[d]=0
					for (var index=0;index < menu_list.length;index++){
						if (menu_list[index][5]==loc){
							total = menu_list[index][7];
							indent[d] ="";
							
							for (var depth_index=1 ; depth_index < NEW_DEPTH+1 ; depth_index++){
								if (depth_index<d){
									if (count[depth_index]==total){
										indent[d] +='\n<td width="10"><img src="images/1x1.gif" border="0" width="19" height="18"/></td>';
									} else {
										//alert(total+ " " +count[depth_index])
										if (total==count[depth_index]){
											indent[d] +='\n<td width="10"><img src="images/1x1.gif" border="0" width="19" height="18"/></td>';
										}else{
											if (counter[d]>count[depth_index]){
												if (depth_index<(d+1)){
													indent[d] +='\n<td width="10"><img src="images/folder_down.gif" border="0" width="19" height="18"/></td>';
												}else{
													indent[d] +='\n<td width="10"><img src="images/folder_junction.gif" border="0" width="19" height="18"/></td>';
												}
											}else{
												indent[d] +='\n<td width="10"><img src="images/folder_down.gif" border="0" width="19" height="18"/></td>';
											}
										}
									}
								}else{
									if (count[depth_index]==total){
										indent[d] +='\n<td width="10"><img src="images/folder_bottom_corner.gif" border="0" width="19" height="18"/></td>';
									} else if (count[depth_index]<total){
										indent[d] +='\n<td width="10"><img src="images/folder_junction.gif" border="0" width="19" height="18"/></td>';
									} else if (count[depth_index]>total){
										indent[d] +='\n<td width="10"><img src="images/folder_down.gif" border="0" width="19" height="18"/></td>';
									} else {
										indent[d] +='\n<td width="10"><img src="images/folder_down.gif" border="0" width="19" height="18"/></td>';
									}
								}
							}
							if (menu_list[index][4]>0){
								if (!toggle[index][1]){
									output 		+= '<tr>'+indent[d];
									output 		+= '\n<td width="10"><a class="layout_menu_folder" href="javascript:link_toggle('+menu_list[index][0]+');"><img src="images/plus.gif" border="0"/></a></td>\n<td width="100%" colspan="'+((depth+1)-d)+'">&nbsp;<a href="javascript:edit('+menu_list[index][0]+');">'+menu_list[index][1]+'</a></td>\n</tr>\n';
								}else{
									
									output 		+= '<tr>'+indent[d];
									output		+= '\n<td width="10"><a class="layout_menu_folder" href="javascript:link_toggle('+menu_list[index][0]+');"><img src="images/minus.gif" border="0"/></a></td>\n<td width="100%" colspan="'+((depth+1)-d)+'">&nbsp;<a href="javascript:edit('+menu_list[index][0]+');">'+menu_list[index][1]+'</a></td>\n</tr>\n';
									output 		+= display_children(NEW_DEPTH+1,toggle[index][0]);
								}
							} else {
								output +='<tr>'+indent[d];
								output +='\n<td><img src="images/folder_right.gif" border="0" /></td>\n<td width="100%" colspan="'+((depth+1)-d)+'">&nbsp;<a href="javascript:edit('+menu_list[index][0]+');">'+menu_list[index][1]+'</a></td>\n</tr>\n';
							}
							count[d]++
						}
					}
					return output;
				}
				
				draw_menu();
			</script>
	</body>
</html>